<?php
/**
 * Created by PhpStorm.
 * User: LiuJiaJun
 * Date: 2019/1/10
 * Time: 15:17
 */

namespace api\storage\service\input;


use api\storage\model\SeatModel;

class BlackInputService extends BaseInputService
{

    public function afterHandle($userId, $type, $storageUuid)
    {
        return $this->resultTemplate(1, $this->dataTemplate($this->materielId, '', $this->count));
    }

    public function checkSeatCode($seatCode, $storageUuid)
    {
        $seatModel = new SeatModel();
        $seat = $seatModel->findByCodeAndStorageUuid($seatCode, $storageUuid);
        if ($this->isEmpty($seat)) {
            return $this->resultTemplate(-1);
        }
        //查看该站位是否被占用
        if ($seat->getData('is_used') == 1) {
            return $this->resultTemplate(-2);
        }
        return $this->resultTemplate(1, ['seat_id' => $seat->getData('seat_id')]);
    }


}